//
//  DianZhuanTableViewController.m
//  1243
//
//  Created by 我的 on 16/3/24.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "DianZhuanTableViewController.h"
#import "DianZhuanCell.h"
#import "SweepViewController.h"
#import "ErWeiMaViewController.h"
#import "JudgeUserLogInTool.h"
@interface DianZhuanTableViewController ()

@end

@implementation DianZhuanTableViewController

static NSString *ID = @"Cell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
//    [self.tableView registerNib:[UINib nibWithNibName:@"DianZhuanCell" bundle:nil] forCellReuseIdentifier:ID];
    
    self.tableView.tableFooterView = [UIView new];
    
    [self setNavBarItem];
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"敬请期待" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}

- (void)setNavBarItem {
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithImage:[UIImage imageNamed:@"nav_1"] highImage:[UIImage imageNamed:@"nav_1"] target:self action:@selector(saoYiSaoBtn) imageEdgeInsets:UIEdgeInsetsMake(0, 10, 15, 0) titleEdgeInsets:UIEdgeInsetsMake(20, -25, 0, 25) title:@"扫一扫"];
    
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barButtonItemWithImage:[UIImage imageNamed:@"nav_3"] highImage:[UIImage imageNamed:@"nav_3"] target:self action:@selector(fuKuanBtn) imageEdgeInsets:UIEdgeInsetsMake(0, 35, 15, -35) titleEdgeInsets:UIEdgeInsetsMake(20, 20, 0, 0) title:@"收款"];
    
    CGRect frame;
    if (WIDTH == 320) {
        frame = CGRectMake(-25, 0, 200, 30);
    } else {
        frame = CGRectMake(0, 0, 200, 30);
    }
    
    UIView *view = [[UIView alloc] initWithFrame:frame];
    
    UITextField *searchFeild = [[UITextField alloc] initWithFrame:frame];
    searchFeild.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入商家或者商品名称" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    searchFeild.textColor = [UIColor redColor];
    searchFeild.font = [UIFont systemFontOfSize:14];
    searchFeild.layer.cornerRadius = searchFeild.frame.size.height/2;
    searchFeild.layer.masksToBounds = YES;
    searchFeild.enabled = NO;
    searchFeild.layer.borderWidth = 1;
    searchFeild.layer.borderColor = [UIColor colorWithRed:52/255. green:147/255. blue:225/255. alpha:1].CGColor;
    [self setLeftViewWithTextField:searchFeild imageName:@"nav_2"];
    [view addSubview:searchFeild];
    
    UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    searchBtn.frame = searchFeild.frame;
    [searchBtn addTarget:self action:@selector(searchBut) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:searchBtn];
    
    self.navigationItem.titleView = view;
}

- (void)searchBut {
    NSLog(@"...");
}

- (void)saoYiSaoBtn {
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
    SweepViewController *a = [[SweepViewController alloc] init];
    [self pushForm:self.navigationController pushToAndHidden:a];
    }
}

- (void)fuKuanBtn {
    if ([JudgeUserLogInTool  JudgeUserLonInStatus]) {
    ErWeiMaViewController *a = [[ErWeiMaViewController alloc] init];
        [self pushForm:self.navigationController pushToAndHidden:a];}
}

//tabBar 隐藏
- (void)pushForm:(UINavigationController *)pushForm pushToAndHidden:(UIViewController *)pushToVC
{
    [pushToVC setHidesBottomBarWhenPushed:YES];
    [pushForm pushViewController:pushToVC animated:YES];
    
}

/**
 *  给UITextField设置右侧的图片
 *
 *  @param textField UITextField
 *  @param imageName 图片名称
 */

-(void)setLeftViewWithTextField:(UITextField *)textField imageName:(NSString *)imageName{
    
    UIImageView *rightView = [[UIImageView alloc]init];
    
    rightView.image = [UIImage imageNamed:imageName];
    rightView.frame = CGRectMake(0, 0, CGRectGetHeight(textField.frame), CGRectGetHeight(textField.frame));
    rightView.contentMode = UIViewContentModeCenter;
    
    textField.leftView = rightView;
    textField.leftViewMode = UITextFieldViewModeAlways;
    textField.backgroundColor = [UIColor blackColor];
    textField.alpha = 0.25;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

//#pragma mark - Table view data source
//
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//
//    return 1;
//}
//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//
//    return 10;
//}
//
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID forIndexPath:indexPath];
//    if (!cell) {
//        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
//    }
//    
//    cell.selectionStyle = UITableViewCellSelectionStyleNone;
//    
//    
//    
//    return cell;
//}
//
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
//    
//    return 200;
//}
//
//#pragma mark - Table View Delegate
//
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// 
//    
//    
//}

@end
